<%@ page pageEncoding="UTF-8"%>
<%@ include file="/common/validate.jsp"%>
<%

	/**
	**获取普通和专家门诊的预约信息 ,从T+1起算 15天  T取当前日期
	**/
	Where where = new Where();
    String ksdm = input.getDesc("dept_id","");
    String kssj = input.getDesc("start_date",getNDays(1));
    String jssj = input.getDesc("end_date",getNDays(DEFAULT_DATA_INTERVAL));
    System.out.print(input);
    HashMap<String, String> map2 = new HashMap<String, String>(4);
	// 开始时间 当天（不含）之后的15天
    map2.put("ksdm", ksdm);//科室代码
    map2.put("kssj", kssj);//开始时间
    map2.put("jssj", jssj);//结束时间
    String url = HOST_BASE_URL_1113 + "/appoint/getallappoint.jsp";
    String json = HttpUtil.post(url,map2);
    Map<Object, Object> map =  JSONUtil.mapFromJson(json);
    Map m= (Map) map.get("data");

    List appointList = (List) m.get("appointList");
    List dutyList = (List) m.get("dutyList");
    if(dutyList!=null && dutyList.size()>0) {
	    for(Object o:dutyList) {
	    	Map tmp=(Map) o;
	    	String name = (String)tmp.get("name");
	    	// 根据名字到表expert取第一条记录的如下字段：expert_id 头像 职称
	    	// 由于根据名字可能存在重名情况  经过确认暂时不考虑
	       
	       List result = QBuilder.db("basedb").queryHql("from Expert where name='"+name+"'");
	       if(result!=null && result.size()>0) {
	    	   Expert emap = (Expert) result.get(0);
	           if(emap.getAvatar() == null || "".equals(emap.getAvatar())){
	        	   emap.setAvatar("");
	           }
	           tmp.put("expert_id", emap.getExpertId());
	           tmp.put("avatar", emap.getAvatar());
	           tmp.put("title", emap.getTitle());
	       }
	    }
    }
    Tools.encryptPrint(out,JSONUtil.toJson(map));
    
%>
